package jccflux;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author MrYoso
 */

import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.awt.event.*;

public class JCCFunctions {
    
 public String new_line(String input, int limit) // Function GERALD G0004
    {
        String[] output = new String[input.length()];
        String ret = "";
        String retfinal = "";
        int div = 0;
        int mx = 0;
        for(int i = 0; i < input.length(); i++)
        {
            output[i] =  "" + input.charAt(i); 
            if(input.charAt(i) == ' ' )
            {
                div = i;
            }
            
            if(i % limit == 0 && div != 0)
            {
               output[div] = "<br/>";
            }
            
        }
        for(int j = 0; j < input.length(); j++)
        {
            ret =  ret + "" +  output[j];
        }
        for(int k = 0; k < ret.length(); k++)
        {
            
            if(ret.charAt(k) == '<')
            {   mx = 0;}
            if(mx > limit + 2)
            {   
                retfinal =  retfinal + "<br/>" + ret.charAt(k);
                mx = 0;
            }
            else
            {   retfinal =  retfinal + "" + ret.charAt(k);}
            mx++;
            
        }
        return retfinal;
    }
    public String getPseudo(String procedure,String type,String dataType,String variable,String content) // Function GERALD G0003
    {
        String pseu = "";//+ procedure+" "+ type+" "+dataType+" "+  variable +" "+ content;
        if(procedure.equals("process"))
        {
           if(type.equals("initialization"))
           {
               
               pseu += ""+variable;
               content = content.trim();
               if(!content.equals(""))
                   pseu += ""+ variable;
           }else
           if(type.equals("arithmetic"))
           {
               pseu += variable+" = "+content;
           }else
           if(type.equals("set"))
           {
               pseu += "set "+content+" to "+variable;
           }else
           if(type.equals("custom"))
           {
               pseu += ""+content;
           }
        }
        if(procedure.equals("condition"))
        {
            pseu +=variable+" "+content;
        }else
        {
            pseu +=variable+" "+content;
        }
        return pseu;
    }

}
